<cfset model = deserializeJSON(generated_mdl) />
<cfloop collection="#model#" item="idx">
	<cfset props = model["#idx#"] />
</cfloop>

<cfoutput>
&lt;cfcomponent extends="#context_name#.app.controller.base_controller"&gt;
	&lt;cffunction access="public" returntype="any" name="index"&gt;
		&lt;cfset #form.table_name# = createObject('component','##application.env.component_location##.app.dao.#form.table_name#').readAll() /&gt;	
		&lt;cfreturn #form.table_name# /&gt;
	&lt;/cffunction&gt;
	<cfloop collection="#props#" item="column_name">
		<cfif structKeyExists(props[column_name], 'key') AND props[column_name]['key'] EQ 'foreign'>
	&lt;cffunction access="public" returntype="any" name="readBy#left(props[column_name]['references'],refind("\.",props[column_name]['references'])-1)#"&gt;
		&lt;cfargument name="model_foreign_key" type="numeric" /&gt;
		&lt;cfset #form.model_name# = createObject('component','##application.env.component_location##.app.dao.#form.table_name#').readBy#left(props[column_name]['references'],refind("\.",props[column_name]['references'])-1)#(arguments.model_foreign_key) /&gt;
		&lt;cfreturn #form.model_name# /&gt;
	&lt;/cffunction&gt;
	</cfif></cfloop>
	&lt;cffunction access="public" returntype="any" name="new"&gt;
		&lt;!--- todo: implement method if required ---&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction access="public" returntype="any" name="show"&gt;
		&lt;cfargument name="model_id_str" type="string" /&gt;
		&lt;cfset #form.model_name#_obj = this.modelfactory.setModelFromURL("#form.model_name#",arguments.model_id_str) /&gt;
		
		&lt;cfset #form.model_name# = createObject('component','##application.env.component_location##.app.dao.#form.table_name#').read(deserializeJSON(#form.model_name#_obj.properties).#form.model_name#) /&gt;
		&lt;cfreturn #form.model_name# /&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction access="public" returntype="any" name="create"&gt;
		&lt;cfargument name="form_str" type="Struct" /&gt;
		&lt;!--- this.modelfactory is defined in the super_class:- base_controller) ---&gt;
		&lt;cfset #form.model_name#_obj = this.modelfactory.setModelFromForm("#form.model_name#",arguments.form_str) /&gt;

		&lt;cftry&gt;
			&lt;cfset insrt_users = createObject('component','##application.env.component_location##.app.dao.#form.table_name#').create(deserializeJSON(#form.model_name#_obj.properties).#form.model_name#) /&gt;
		&lt;cfcatch type="any"&gt;
			&lt;cfset request.flash["error"] = cfcatch.Message /&gt;
			&lt;cfset request.flash["extended_info"] = "(Template ##cfcatch.tagcontext[1].template##, Line: ##cfcatch.tagcontext[1].line##)" /&gt;
		&lt;/cfcatch&gt;
		&lt;/cftry&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction access="public" returntype="any" name="edit"&gt;
		&lt;cfargument name="form_str" type="Struct" /&gt;
		&lt;!--- todo: implement method if required ---&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction access="public" returntype="any" name="update"&gt;
		&lt;cfargument name="form_str" type="Struct" /&gt;
		
		&lt;!--- this.modelfactory is defined in the super_class:- base_controller) ---&gt;
		&lt;cfset #form.model_name#_obj = this.modelfactory.setModelFromForm("#form.model_name#",arguments.form_str) /&gt;

		&lt;cftry&gt;
			&lt;cfset insrt_users = createObject('component','##application.env.component_location##.app.dao.#form.table_name#').update(deserializeJSON(#form.model_name#_obj.properties).#form.model_name#) /&gt;
		&lt;cfcatch type="any"&gt;
			&lt;cfset request.flash["error"] = cfcatch.Message /&gt;
			&lt;cfset request.flash["extended_info"] = "(Template ##cfcatch.tagcontext[1].template##, Line: ##cfcatch.tagcontext[1].line##)" /&gt;
		&lt;/cfcatch&gt;
		&lt;/cftry&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction access="public" returntype="any" name="delete"&gt;
		&lt;cfargument name="model_id_str" type="string" /&gt;
		&lt;cfset #form.model_name#_obj = this.modelfactory.setModelFromURL("#form.model_name#",arguments.model_id_str) /&gt;
		
		&lt;cftry&gt;
			&lt;cfset delete_#form.model_name# = createObject('component','##application.env.component_location##.app.dao.#form.table_name#').delete(deserializeJSON(#form.model_name#_obj.properties).#form.model_name#) /&gt;
			
		&lt;cfcatch type="any"&gt;
			&lt;cfset request.flash["error"] = cfcatch.Message /&gt;
			&lt;cfset request.flash["extended_info"] = "(Template ##cfcatch.tagcontext[1].template##, Line: ##cfcatch.tagcontext[1].line##)" /&gt;
		&lt;/cfcatch&gt;
		&lt;/cftry&gt;
		
	&lt;/cffunction&gt;
&lt;/cfcomponent&gt;
</cfoutput>